import { FieldBase, IFieldOptions } from './field-base.interface'

export class ChanMerSelectField extends FieldBase<any> {
  controlType = 'chan-mer-select'
  options: any[]
  labelKeyOfOption = 'chanMerID'
  compareWith: (o1: any, o2: any) => boolean = (o1: any, o2: any) => (o1 && o2 ? o1.id === o2.id : o1 === o2)

  constructor(options: IFieldOptions<any> = {}) {
    super(options)
    this.options = options['options'] || []
    if (options.compareWith) {
      this.compareWith = options.compareWith
    }
    if (options['labelKeyOfOption']) {
      this.labelKeyOfOption = options['labelKeyOfOption']
    }
  }
}
